'''
Mock Mail Sender.
'''
import logging
from mails.html_repo_formatter import HtmlFormatter

class NotSendingMailSender: 
    """
    Mock mail sender. Instead of sending, it stores mails for querying.
    """
    def __init__(self):
        self._sent_mails = []
        
    def send_mail(self, email, subject, processors):
        """
        Just store and log the mail - do not send it.
        """
        logging.info("Mail to " + str(email) + " with subject " + subject + \
                     " from processors " + str(processors))
        self._sent_mails.append({
                                 "email": email ,
                                 "subject": subject,
                                 "processors" : processors
                                })
        title = "Title " + subject
        formatter = HtmlFormatter(title, processors)
        html = formatter.html_format_page()
        return html
        
    def get_sent_mails(self):
        """
        Retrieves all sent mails.
        """
        return self._sent_mails
    
    def clear_sent_mails(self):
        """
        Removes all sent mails for clean state.
        """
        self._sent_mails = []
